package com.tanhua.manage.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.tanhua.manage.domain.AnalysisByDay;
import com.tanhua.manage.vo.DataPointVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.Date;
import java.util.List;

@Mapper
public interface AnalysisByDayMapper extends BaseMapper<AnalysisByDay> {
    @Select("SELECT * FROM tb_analysis_by_day WHERE record_date =#{today}")
    AnalysisByDay findBydate(String today);

    @Select("SELECT sum(DISTINCT user_id) FROM tb_log ")
    Long totalusercount();

    @Select("SELECT record_date total, num_registered amount FROM tb_analysis_by_day " +
            "WHERE record_date BETWEEN #{sd} AND #{ed} ")
    List<DataPointVo> countRegister(@Param("sd") Date sd,@Param("ed") Date ed);
    @Select("SELECT record_date total, num_active amount FROM tb_analysis_by_day " +
            "WHERE record_date BETWEEN #{sd} AND #{ed} ")
    List<DataPointVo> countActive(@Param("sd") Date sd,@Param("ed") Date ed);
    @Select("SELECT record_date total, num_retention1d amount FROM tb_analysis_by_day " +
            "WHERE record_date BETWEEN #{sd} AND #{ed} ")
    List<DataPointVo> countRetention(@Param("sd") Date sd,@Param("ed") Date ed);
}